package com.example.rabbit.demora.simple;

import com.example.rabbit.demora.config.SenderCallBack;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * User: Amosd
 * Date: 2019/8/1
 * Time: 15:02
 */

@RestController
public class SimpleRabbitMqPro {

    @Autowired
    private SenderCallBack senderCallBack;


    @RequestMapping("test/simple")
    public String simplePro(){
       this.stringSend();
     return "";
    }

    private void stringSend() {
//        Date date = new Date();
//        String dateString = new SimpleDateFormat("YYYY-mm-DD hh:MM:ss").format(date);
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime now = LocalDateTime.now();
        String dateString = now.format(dateTimeFormatter);
        System.out.println("[string] send msg:" + dateString);
        // 第一个参数为刚刚定义的队列名称
        senderCallBack.send("boot-test",dateString);
    }
}
